package cn.geminis.crypto.csp.soft.empty;

import cn.geminis.crypto.core.key.PublicKey;
import cn.geminis.crypto.csp.AbstractAsymmetricBlockCipher;
import org.bouncycastle.crypto.CipherParameters;

import java.util.Arrays;

/**
 * @author Allen
 */
public class EmptyAsymmetricBlockCipher extends AbstractAsymmetricBlockCipher {

    private final PublicKey publicKey;

    public EmptyAsymmetricBlockCipher(PublicKey publicKey) {
        this.publicKey = publicKey;
    }

    @Override
    public byte[] getPublicKey() {
        return this.publicKey.getEncoded();
    }

    @Override
    public void close() {
        //nothing to close
    }

    @Override
    public void init(boolean b, CipherParameters cipherParameters) {
        //nothing to initial
    }

    @Override
    public int getInputBlockSize() {
        return 0;
    }

    @Override
    public int getOutputBlockSize() {
        return 0;
    }

    @Override
    public byte[] processBlock(byte[] bytes, int start, int length) {
        return Arrays.copyOfRange(bytes, start, start + length);
    }
}
